<script setup lang="ts">
import type { Template } from '@/types/template'
import { useMemberStore } from '@/stores'

// 定义props接收
defineProps<{
  list: Template[]
}>()

// 线路点击处理
const onClickTemplate = (id: number) => {
  let user_id = 0
  // 获取会员信息
  const memberStore = useMemberStore()
  if (memberStore.profile != null) {
    user_id = memberStore.profile.id
  }
  uni.navigateTo({ url: `/pages/template/see?id=${id}&user_id=${user_id}` })
}
</script>

<template>
  <view class="template-item" @click="onClickTemplate(it.id)" v-for="it in list" :key="it.id">
    <image :src="it.pic" />
    <view class="template-title-bar">
      <view class="title u-line-2">{{ it.name }}</view>
      <view class="market-price">
        <text class="c-main"
          >￥<text>{{ it.market_price }}</text></text
        >起
      </view>
    </view>
  </view>
</template>

<style lang="scss">
@import '@/components/styles/HxTemplate.scss';
</style>
